package com.zm.demo.disruptor;

/**
 * @author z01140
 * @Package: com.zm.demo.disruptor
 * @Description:
 * @CreateDate 2023/8/29 10:56
 * @UpdateDate 2023/8/29 10:56
 */
public class OpTest {

    public static void main(String[] args) {
        t();// 2000ms
        t1(); // 260ms
    }

    public static final void t(){
        long s = System.currentTimeMillis();
        int n = 16;
        int sum = 0;
        for (int i = 0; i < 1000000000; i++) {
            int i1 = i % n;
            sum += i1;
        }
        System.out.println("MOD:" + (System.currentTimeMillis() - s) + sum);
    }

    public static final void t1(){
        long s = System.currentTimeMillis();
        int n = 16;
        int sum = 0;
        for (int i = 0; i < 1000000000; i++) {
            int i1 = i & (n-1);
            sum += i1;
        }
        System.out.println("AND:" + (System.currentTimeMillis() - s) + sum);
    }
}
